package com.example.fasttalk.setting;

import com.example.fasttalk.model.FastTalkSettingDataModel;
import com.example.fasttalk.model.intfc.FastTalkSettingData;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import org.jetbrains.annotations.NotNull;

/**
 * @author SundayLi
 * @date 2023/2/24 18:15
 */
@State(name = "FastTalkSettings",storages = @Storage("plugin.xml"))
public class FastTalkSettings implements PersistentStateComponent<FastTalkSettingDataModel> {
  FastTalkSettingDataModel fastTalkSettingDataModel = new FastTalkSettingDataModel();

  public static FastTalkSettings getInstance() {
    return ApplicationManager.getApplication().getService(FastTalkSettings.class);
  }

  @Override
  public @NotNull FastTalkSettingDataModel getState() {
    return fastTalkSettingDataModel;
  }

  @Override
  public void loadState(@NotNull FastTalkSettingDataModel state) {
    this.fastTalkSettingDataModel = state;
  }
}
